package com.library.controller;

import com.library.entity.OaDepartment;
import com.library.entity.OaDepartmentUserLink;
import com.library.entity.OaDepartmentUserLinkExt;
import com.library.service.OaDepartmentUserLinkServiceImpl;
import com.library.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ido
 * @since 2024-12-14
 */
@Controller
public class OaDepartmentUserLinkController {

    public static final String prefix = "/api/oadepartmentlink";

    @Autowired
    private OaDepartmentUserLinkServiceImpl oaDepartmentUserLinkUserLinkService;

    @RequestMapping("/oadepartmentlink.html")
    public ModelAndView adminBooks() {
        ModelAndView modelAndView = new ModelAndView("oadepartmentlink");
        return modelAndView;
    }

    @RequestMapping(path = prefix + "/list",
            method = RequestMethod.POST
    )
    @ResponseBody
    public BaseResult list(@RequestBody OaDepartmentUserLinkExt oaDepartmentUserLink) {
        List<OaDepartmentUserLinkExt> list = this.oaDepartmentUserLinkUserLinkService.list(oaDepartmentUserLink);
        return BaseResult.successWithData(list);
    }

    @RequestMapping(path = prefix + "/add",
            method = RequestMethod.POST
    )
    @ResponseBody
    public BaseResult add(@RequestBody OaDepartmentUserLink oaDepartmentUserLink) {
        this.oaDepartmentUserLinkUserLinkService.add(oaDepartmentUserLink);
        return BaseResult.success();
    }

    @RequestMapping(path = prefix + "/delete",
            method = RequestMethod.POST
    )
    @ResponseBody
    public BaseResult delete(@RequestBody OaDepartmentUserLink oaDepartmentUserLink) {
        this.oaDepartmentUserLinkUserLinkService.delete(oaDepartmentUserLink);
        return new BaseResult();
    }

    @RequestMapping(path = prefix + "/update",
            method = RequestMethod.POST
    )
    @ResponseBody
    public BaseResult update(@RequestBody OaDepartmentUserLink oaDepartmentUserLink) {
        this.oaDepartmentUserLinkUserLinkService.update(oaDepartmentUserLink);
        return new BaseResult();
    }

    @RequestMapping(path = prefix + "/detail",
            method = RequestMethod.POST
    )
    @ResponseBody
    public BaseResult detail(@RequestBody OaDepartmentUserLink oaDepartmentUserLink) {
        OaDepartmentUserLinkExt oaDepartmentUserLink1 = this.oaDepartmentUserLinkUserLinkService.detail(oaDepartmentUserLink);
        return BaseResult.successWithData(oaDepartmentUserLink1);
    }


}
